package gc3d.gridspring;

import gc3d.database.DBSettings;
import gc3d.database.GridPovDB;
import gc3d.ftp.FTPSettings;
import gc3d.ftp.GridPovFTP;
import gc3d.griddata.GridData;
import gc3d.griddata.GridPovData;

import java.io.IOException;
import java.sql.SQLException;


/**
 * @author Pierrick
 *
 */
public class GridTest {

	public static void main(String[] args) {
		System.out.println("main test gridpovrun start:");

		StringBuffer povbuff = new StringBuffer();
		povbuff.append("#version 3.6;");
		povbuff.append("global_settings { assumed_gamma 1.0 }");
		povbuff.append("camera{ ultra_wide_angle");
		povbuff.append("  angle 75");
		povbuff.append("  right x*image_width/image_height");
		povbuff.append("  location  <0.0 , 1.0 ,-3.0>");
		povbuff.append("  look_at   <0.0 , 0.0 , 0.0> }");
		povbuff.append("light_source{ <1500,2500,-2500> color rgb<1,1,1> }");
		povbuff.append("sky_sphere{ pigment{color rgb<1,1,1>}}");
		povbuff.append("sphere{ <0,0,0>, 0.25");
		povbuff.append("  texture {");
		povbuff.append("    pigment{ rgb<1,0,0> }");
		povbuff.append("    finish { diffuse 0.9 phong 1}");
		povbuff.append("  }");
		povbuff.append("  translate < 1.0, 0, 0>");
		povbuff.append("  rotate < 0,360*clock 0>");
		povbuff.append("}");

		try {
			GridPovData gpd   = new GridPovData(100, 100, 3, 0, 1, false, 0.1, 
					2, "povrayfile.pov", povbuff.toString().getBytes());
			GridPovFTP  gpftp = new GridPovFTP(FTPSettings.getFTPhost(), FTPSettings.getFTPport(), FTPSettings.getFTPuser(), FTPSettings.getFTPpass());
			GridPovDB   gpdb  = new GridPovDB(DBSettings.getDBURL(),DBSettings.getDBuser(),DBSettings.getDBpass());
			GridData    gd    = new GridData(gpd, gpftp, gpdb, povbuff.toString().getBytes());
			GridPovRun  gpr   = new GridPovRun(gd, 5, 800);
			gpr.start();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

		System.out.println("main test gridpovrun finished.");
	}
}
